package com.wf.LeetCode;

/**
 * @author mpk
 * @since 2024/6/10 18:26:10
 */
public class ReturnToBoundaryCount {

    public static void main(String[] args) {
        int [] nums = {2,3,-5};
        int [] nums1 = {3,2,-3,-4};

        System.out.println(returnToBoundaryCount(nums));
        System.out.println(returnToBoundaryCount(nums1));
    }

    public static int returnToBoundaryCount(int[] nums) {

        int count = 0;
        int sum = 0;

        for (int num : nums) {

            if ((sum += num) == 0) {
                count++;
            }

        }
        return count;

    }

}
